//
//  WSUserRequest.m
//  CharonTVProject
//
//  Created by karong on 2023/7/31.
//

#import "WSUserRequest.h"

@implementation WSUserRequest

+ (void)logincharonTV_WithSuccess:(charonTV_AnyObjectBlock)success failed:(Failure)failed {
    NSString * url = API_CHARONTV_LOGIN;
    NSString * language = [[NSLocale preferredLanguages] firstObject];
    NSDictionary * parameters = @{@"token":WSEmptyStr(appUserCenter.qtoken),
                                  @"uuid":[WSUserCenter uuid],
                                  @"device_lang":WSEmptyStr(language)
    };
    [self postWithURLString:url parameters:parameters success:^(NSDictionary * _Nonnull responseDict) {
        WSUserCenter * userCenter = [WSUserCenter mj_objectWithKeyValues:responseDict];
        [appUserCenter logIn:userCenter];
        success(userCenter);
    } failure:failed];
}

+ (void)getcharonTV_UserInfoWithUser_id:(NSInteger)user_id success:(charonTV_AnyObjectBlock)success failed:(Failure)failed {
    NSString * url = API_CHARONTV_USER_INFO;
    NSDictionary * parameters = @{@"user_id":@(user_id)};
    [self postWithURLString:url parameters:parameters success:^(NSDictionary * _Nonnull responseDict) {
        WSUserCenter * user = [WSUserCenter mj_objectWithKeyValues:responseDict];
        success(user);
    } failure:failed];
}

@end
